/*
 * Project: yygh-parent
 *
 * File Created at 2023/7/26
 *
 * 自定义时间格式代替DATE标签：2023-07-26 19:35:19:35
 */
package com.atguigu.yygh.order.controller;

import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.order.service.ScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author 用户名
 * @Type ScheduleController.java
 * @Desc
 * @date 2023/7/26 19:35
 */
@Api("排班管理接口")
@RestController
//@CrossOrigin
@RequestMapping("/admin/hosp/schedule")
@Slf4j
public class ScheduleController {
    @Autowired
    ScheduleService scheduleService;
    //根据医院号和小科室号得到这个科室的预约情况
    @ApiOperation(value = "得到科室预约情况")
    @GetMapping("getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRule(
            @ApiParam(name = "page", value = "page", required = true)   @PathVariable Integer page,
            @ApiParam(name = "limit", value = "limit", required = true)   @PathVariable Integer limit,
            @ApiParam(name = "hoscode", value = "hoscode", required = true)   @PathVariable String hoscode,
            @ApiParam(name = "depcode", value = "depcode", required = true)   @PathVariable String depcode
    ) {
        Map<String, Object> stringObjectMap = scheduleService.selectPageByHoscodeAndDepcode(page, limit, hoscode, depcode);
        return Result.ok(stringObjectMap);
    }
    @ApiOperation(value = "查询排班详细信息")
    @GetMapping("getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public Result getScheduleDetail( @PathVariable String hoscode,
                                     @PathVariable String depcode,
                                     @PathVariable String workDate) {
        List<Schedule> list = scheduleService.getDetailSchedule(hoscode,depcode,workDate);
        return Result.ok(list);
    }

    @ApiOperation(value = "查询排班详细信息")
    @GetMapping("getScheduleByScheduleId/{scheduleId}")
    public Result getScheduleByScheduleId( @PathVariable String scheduleId) {
        Schedule byId = scheduleService.getById(scheduleId);

        return Result.ok(byId);
    }
    @ApiOperation(value = "查询排班详细信息")
    @RequestMapping(value="/saveSchedule" ,method= RequestMethod.POST)
    public Result saveSchedule(@RequestBody Schedule schedule) {
        System.out.println("okok");
        scheduleService.saveSchedule(schedule);


        return Result.ok();
    }

}


/**
 * Revision history
 * -------------------------------------------------------------------------
 * <p>
 * Date Author Note
 * -------------------------------------------------------------------------
 * 2023/7/26 用户名 create
 */ 
